package com.ruoyi.wareManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wareManagement.domain.InventoryOverview;
import com.ruoyi.wareManagement.service.IInventoryOverviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存查询Controller
 * 
 * @author admin
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/wareManagement/inventoryInquiry")
public class InventoryOverviewController extends BaseController
{
    @Autowired
    private IInventoryOverviewService inventoryOverviewService;

    /**
     * 查询库存查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:list')")
    @GetMapping("/list")
    public TableDataInfo list(InventoryOverview inventoryOverview)
    {
        startPage();
        List<InventoryOverview> list = inventoryOverviewService.selectInventoryOverviewList(inventoryOverview);
        return getDataTable(list);
    }

    /**
     * 导出库存查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:export')")
    @Log(title = "库存查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InventoryOverview inventoryOverview)
    {
        List<InventoryOverview> list = inventoryOverviewService.selectInventoryOverviewList(inventoryOverview);
        ExcelUtil<InventoryOverview> util = new ExcelUtil<InventoryOverview>(InventoryOverview.class);
        util.exportExcel(response, list, "库存查询数据");
    }

    /**
     * 获取库存查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:query')")
    @GetMapping(value = "/{inquiryId}")
    public AjaxResult getInfo(@PathVariable("inquiryId") Long inquiryId)
    {
        return success(inventoryOverviewService.selectInventoryOverviewByInquiryId(inquiryId));
    }

    /**
     * 新增库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:add')")
    @Log(title = "库存查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InventoryOverview inventoryOverview)
    {
        return toAjax(inventoryOverviewService.insertInventoryOverview(inventoryOverview));
    }

    /**
     * 修改库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:edit')")
    @Log(title = "库存查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InventoryOverview inventoryOverview)
    {
        return toAjax(inventoryOverviewService.updateInventoryOverview(inventoryOverview));
    }

    /**
     * 删除库存查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryInquiry:remove')")
    @Log(title = "库存查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inquiryIds}")
    public AjaxResult remove(@PathVariable Long[] inquiryIds)
    {
        return toAjax(inventoryOverviewService.deleteInventoryOverviewByInquiryIds(inquiryIds));
    }



}
